import { request } from '@/framework/utils/request-jdz';

// 储位树结构数据
export const getStorageList = (id: string | number) => {
  return request(
    {
      url: `storages/${id}/childrens`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 盒信息
export const getTableList = (params: { id: number | string }) => {
  return request(
    {
      // url: '/storage/box/by-instance-id',
      url: '/storage/box/instance/getDetail',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

/**
 * 设备
 */
// 新增自有设备信息
export const addEquipment = (params) => {
  return request(
    {
      url: 'storages/add',
      method: 'post',
      data: params,
      timeout: 1800000,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 导入三方设备信息
export const addTripartiteEquipment = (params) => {
  return request(
    {
      url: 'storages/import',
      method: 'post',
      data: params,
      timeout: 1800000,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 修改自有设备信息
export const editEquipment = (params) => {
  return request(
    {
      url: 'storages/edit',
      method: 'post',
      data: params,
      timeout: 1800000,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 修改三方设备信息
export const editTripartiteEquipmentById = (id, data) => {
  return request(
    {
      url: `storages/${id}`,
      method: 'put',
      data,
      timeout: 1800000,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 新增保藏区
export const addStorage = (params: API.AddStorageInfo) => {
  return request(
    {
      url: 'storages',
      method: 'post',
      data: params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// md5下载
export const getMd5 = (md5) => {
  return request(
    {
      url: `/md5/${md5}`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 查询储位信息
export const getStorage = (id) => {
  return request(
    {
      url: `storages/${id}`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 修改储位
export const putStorage = (params: API.AddEquipmentInfo) => {
  return request(
    {
      url: `storages/${params.id}`,
      method: 'put',
      data: params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 绑定试管盒
export const bindBox = (params: { epcId: string; storageId: string }) => {
  return request(
    {
      url: 'storages/bindStorageBox',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};
// 解绑试管盒
export const unBindBox = (params: { epcId: string; storageId: string }) => {
  return request(
    {
      url: 'storages/unbindStorageBox',
      method: 'get',
      params,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 删除设备、保藏区
export const delSaveOrEquipmentById = (storageId: string) => {
  return request(
    {
      url: `storages/${storageId}`,
      method: 'delete',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

export const getUnBindBox = (serial) => {
  return request(
    {
      url: `storage/box/instance/emptyBox?serial=${serial}`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 获取样本盒信息
export const getBoxInfo = (id) => {
  return request(
    {
      url: `/storage/box/${id}`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 新增层级
export const addLevel = (parentId) => {
  return request(
    {
      url: `/storages/${parentId}/addChildren`,
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// excel上传
export const uploadExcel = (data) => {
  return request(
    {
      url: 'specimens/fix/gene',
      method: 'post',
      headers: {
        'Content-Type': 'multipart/form-data',
      },
      data,
    },
    {
      isGetDataDirectly: false,
    },
  );
};

// 测点
export const getPoint = () => {
  return request(
    {
      url: '/iceBoxWarn/getPosList',
      method: 'get',
    },
    {
      isGetDataDirectly: false,
    },
  );
};
